// 图片识别功能
const cloud = require('wx-server-sdk')
const pictureModel = require('./picture.js');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const logger = cloud.logger()
  var result = '参数错误';
  if (event.str64 != null) {
    result = pictureModel.getAccessToken(event.str64)
  }
  if (event.cloudFunc) {
    result = await db.collection('picture').get()
  }
  logger.error({
    result: result
  })
  return result
}